package com.example.edwincompose.ui.page

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.edwincompose.R
import kotlinx.coroutines.delay


@Composable
fun SplashPage(onNextPage: () -> Unit) {
    LaunchedEffect(Unit) {
        delay(3000)
        onNextPage.invoke()
    }
    Box (Modifier
        .background(colorResource(R.color.primary))
        .fillMaxWidth()
        .fillMaxHeight(),
            contentAlignment = Alignment.Center // 关键：设置内容居中
    ){
        Text(
            text="Splash Page",
            fontSize = 32.sp,
            color = colorResource(R.color.white),
            fontWeight = Bold

        )
    }

}

@Preview(showBackground = true)
@Composable
fun SplashPage() {
    SplashPage{}
}